// A short program to demonstrate the use of for and while loops in
// C++. Every loop in this program displays the integers 0 through 9
#include <iostream>

int main()
{
  int i = 0;
  bool should_loop = true;

  // A while loop in C++ is similar to many other languages. 
  i = 0;
  while(should_loop == true) {
    std::cout << i << "  ";
    i = i+1;
    if(i >= 10) should_loop = false;
  }
  std::cout << std::endl;

  // A for loop allows you to iterate a certain number of times:
  for(i = 0; i < 10; i = i+1) {
    std::cout << i << "  ";
  }
  std::cout << std::endl;

  // Many times you will see loops like the one below:
  for(int j = 0; j < 10; j++) {
    std::cout << j << "  ";
  }
  std::cout << std::endl;

  return 0;
}
